package com.concurrent.threadPoolTest;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-05-13 14:29
 */
@Slf4j
public class ThreadPoolTest1 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);//3个线程
        for(int i=0;i<10;++i){
            final int now = i;
            executorService.execute(()->{
                log.info("now thread {}",now);
            });
        }
        executorService.shutdown();

         executorService = Executors.newSingleThreadExecutor();//单线程
        for(int i=0;i<10;++i){
            final int now =  i;
            executorService.execute(()->{
                log.info("now thread {}",now);
            });
        }
        executorService.shutdown();
    }
}
